@calculate_time
def a():
    # 加载音频文件
    file_path = './recod/output20250512-004204.mp3'   #combined.wav output20250509-001319.mp3
    y, sr = librosa.load(file_path, dtype='float32',sr=600) #1184956416
    print(y.dtype) #
    print(y[:1000], sr)
    print(len(y))

    # 显示音频波形
    plt.figure(figsize=(10, 4))
    librosa.display.waveshow(y, sr=600) #sr 44k
    plt.title('Snoring Audio Waveform')
    plt.show()

#浏览器画图
@calculate_time
def b():
    # 加载音频文件
    file_path = './recod/output20250512-004204.mp3'  #combined.wav output20250509-001319.mp3
    y, sr = librosa.load(file_path, dtype='float32',sr=4410  ) #1184956416
    x = range(len(y))

    fig = px.line(x=x,
                  y=y,
                  title="db数据",
                  labels={"x": "time", "y": "db"})


    #fig.show()
    fig.write_image("iris_plot.jpg",width=1200, height=300,scale=1,   )  # 默认保存为PNG


